package cn.tradewin.advisor.commons.selectmodel;

import java.util.ArrayList;
import java.util.List;

import org.apache.tapestry5.OptionGroupModel;
import org.apache.tapestry5.OptionModel;
import org.apache.tapestry5.internal.OptionModelImpl;
import org.apache.tapestry5.util.AbstractSelectModel;

import cn.tradewin.advisor.persist.model.CodeLabel;

public class CodeLabelSelectModel extends AbstractSelectModel {

	private final List<CodeLabel> records;
	
	public CodeLabelSelectModel(List<CodeLabel> records) {
		this.records = records;
	}
	
	@Override
	public List<OptionGroupModel> getOptionGroups() {
		return null;
	}

	@Override
	public List<OptionModel> getOptions() {
		List<OptionModel> options = new ArrayList<OptionModel>();
        for (CodeLabel record : records) {
            options.add(new OptionModelImpl(record.getLabel(), record.getCode()));
        }
        return options;
	}
}
